Physical hardware info dom0 op.
40278d91ZjLhxdjjrGe8HEdwHLj5xQ tools/examples/netbsd
401d7e16NpnVrFSsR7lKKKfTwCYvWA tools/examples/xc_dom_control.py
401d7e16RJj-lbtsVEjua6HYAIiKiA tools/examples/xc_dom_create.py
+403b7cf7J7FsSSoEPGhx6gXR4pIdZg tools/examples/xc_physinfo.py
401d7e16X4iojyKopo_j63AyzYZd2A tools/examples/xc_vd_tool.py
40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/xendomains
3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
--- /dev/null
+#!/usr/bin/env python
+
+# Get information about the physical host machine
+
+import Xc
+
+xc = Xc.new()
+
+info = xc.physinfo()
+
+fmt_info = [ ( 'CPU cores', info['cores']),
+ ('Hyperthreads per core', info['ht_per_core']),
+ ('CPU Speed (MHz)', info['cpu_khz'] / 1000),
+ ('Total physical mem (MB)', info['total_pages'] / 256),
+ ('Free physical mem (MB)', info['free_pages'] / 256) ]
+
+
+for (item, val) in fmt_info:
+ print "%-23s" % item, ':', val
+
u64 nr_sectors;
} xc_vbdextent_t;
+typedef struct {
+ int ht_per_core;
+ int cores;
+ unsigned long total_pages;
+ unsigned long free_pages;
+ unsigned long cpu_khz;
+} xc_physinfo_t;
+
int xc_vbd_create(int xc_handle,
u64 domid,
unsigned short vbdid,
unsigned int max_chars,
int clear);
+int xc_physinfo(int xc_handle,
+ xc_physinfo_t *info);
#endif /* __XC_H__ */
return ret;
}
+
+int xc_physinfo(int xc_handle,
+ xc_physinfo_t *put_info)
+{
+ int ret;
+ dom0_op_t op;
+ dom0_physinfo_t *got_info = &op.u.physinfo;
+
+ op.cmd = DOM0_PHYSINFO;
+ op.interface_version = DOM0_INTERFACE_VERSION;
+
+ if((ret = do_dom0_op(xc_handle, &op))) return ret;
+
+ put_info->ht_per_core = got_info->ht_per_core;
+ put_info->cores = got_info->cores;
+ put_info->total_pages = got_info->total_pages;
+ put_info->free_pages = got_info->free_pages;
+ put_info->cpu_khz = got_info->cpu_khz;
+
+ return 0;
+}
+
return PyString_FromStringAndSize(str, (ret < 0) ? 0 : ret);
}
+static PyObject *pyxc_physinfo(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ XcObject *xc = (XcObject *)self;
+ PyObject *ret_obj;
+ int xc_ret;
+ xc_physinfo_t info;
+
+ xc_ret = xc_physinfo(xc->xc_handle, &info);
+
+ if(!xc_ret)
+ {
+ ret_obj = Py_BuildValue("{s:i,s:i,s:l,s:l,s:l}",
+ "ht_per_core", info.ht_per_core,
+ "cores", info.cores,
+ "total_pages", info.total_pages,
+ "free_pages", info.free_pages,
+ "cpu_khz", info.cpu_khz);
+ }
+ else
+ {
+ ret_obj = Py_BuildValue(""); /* None */
+ }
+
+ return ret_obj;
+}
+
static PyMethodDef pyxc_methods[] = {
{ "domain_create",
(PyCFunction)pyxc_domain_create,
" clear [int, 0]: Bool - clear the ring after reading from it?\n\n"
"Returns: [str] string is empty on failure.\n" },
+ { "physinfo",
+ (PyCFunction)pyxc_physinfo,
+ METH_VARARGS, "\n"
+ "Get information about the physical host machine\n"
+ "Returns [dict]: information about the hardware"
+ " [None]: on failure.\n" },
+
{ NULL, NULL, 0, NULL }
};
op->u.readconsole.count,
op->u.readconsole.cmd);
}
- break;
+ break;
+
+ case DOM0_PHYSINFO:
+ {
+ extern int phys_proc_id[];
+ extern unsigned long cpu_khz;
+
+ dom0_physinfo_t *pi = &op->u.physinfo;
+
+ int old_id = phys_proc_id[0];
+ int ht = 0;
+
+ while( ( ht < smp_num_cpus ) && ( phys_proc_id[ht] == old_id ) ) ht++;
+ pi->ht_per_core = ht;
+ pi->cores = smp_num_cpus / pi->ht_per_core;
+ pi->total_pages = max_page;
+ pi->free_pages = free_pfns;
+ pi->cpu_khz = cpu_khz;
+
+ copy_to_user(u_dom0_op, op, sizeof(*op));
+ ret = 0;
+ }
+ break;
+
default:
ret = -ENOSYS;
* This makes sure that old versions of dom0 tools will stop working in a
* well-defined way (rather than crashing the machine, for instance).
*/
-#define DOM0_INTERFACE_VERSION 0xAAAA0006
-
+#define DOM0_INTERFACE_VERSION 0xAAAA0007
/*
* The following is all CPU context. Note that the i387_ctxt block is filled
unsigned long phys_addr;
} dom0_gettbufs_t;
+/*
+ * Get physical information about the host machine
+ */
+#define DOM0_PHYSINFO 22
+typedef struct dom0_physinfo_st
+{
+ int ht_per_core;
+ int cores;
+ unsigned long cpu_khz;
+ unsigned long total_pages;
+ unsigned long free_pages;
+} dom0_physinfo_t;
+
typedef struct dom0_op_st
{
unsigned long cmd;
dom0_readconsole_t readconsole;
dom0_pincpudomain_t pincpudomain;
dom0_gettbufs_t gettbufs;
+ dom0_physinfo_t physinfo;
} u;
} dom0_op_t;